import {defineStore} from 'pinia'
import {ref} from 'vue'
import {type PageRequest} from '@/types/PageRequest'
import {Platform, UpdateMethod, IsForce, type AppVersionListAO, type AppVersionVO} from "./ApVersionTypes"

export const useApVersionStore =  defineStore('ApVersionStore', ()=>{
    
    let willUploadAppVersionDialog = ref<boolean>(false);
    let uploadAppVersionPlatform = ref<string>("Android");
    let uploadAppVersionMethod = ref<UpdateMethod>(UpdateMethod.APK);
    let uploadAppVersionIsForce = ref<IsForce>(IsForce.yes);
    let uploadAppVersionInfo = ref<string>();
    let uploadAppVersionNumber = ref<string>()
    let uploadAppVersionFileUrl = ref<string>()
    let uploadAppVersionWgtUrl = ref<string>()

    let appVersionListAO = ref<AppVersionListAO>({
        platform: Platform.Android,
        pageNum: 1,
        pageSize: 20,
    })

    let updateAppVersion = ref<AppVersionVO>()

    let willUpdateAppVersionDialog = ref<boolean>(false);
    
    // 放大二维码
    let showQrCodeDialog = ref<boolean>(false)
    let showQrCode = ref<string>()
    let showQrCodeVersion = ref<string>()

    return {
        willUploadAppVersionDialog,
        uploadAppVersionPlatform,
        uploadAppVersionMethod,
        uploadAppVersionIsForce,
        uploadAppVersionInfo,
        uploadAppVersionNumber,
        uploadAppVersionFileUrl,
        uploadAppVersionWgtUrl,

        appVersionListAO,
        updateAppVersion,
        willUpdateAppVersionDialog,

        showQrCodeDialog,
        showQrCode,
        showQrCodeVersion,
    }
},{
    persist: true,
})

